package com.zucc.util;

import com.zucc.service.base.PageData;

import java.util.List;
import java.util.Objects;

/**
 * @author : charspan
 * @Description :
 * @create : 2021-11-29 4:58 下午
 */
public class MyPageUtil {

    public static <V, T> PageData<T> convert(PageData<V> from, Class<T> to) {
        if (Objects.isNull(from)) {
            return null;
        }
        List<V> fromList = from.getList();
        List<T> toList = MyBeanUtil.converterList(fromList, to);
        PageData<T> toPageData = new PageData<>();
        toPageData.setList(toList);
        toPageData.setPageNum(from.getPageNum());
        toPageData.setPageSize(from.getPageSize());
        toPageData.setTotal(from.getTotal());
        return toPageData;
    }

}
